package com.ganmiao.server.supplier.mapper;


import com.ganmiao.server.supplier.entity.Tender;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

public interface TenderMapper {

    @Select("<script>" +
            "select * from tenders " +
            "<if test='id != null' >" +
            "where id = #{id}" +
            "</if>" +
            "</script>")
    public Tender tendersGet(Integer id);

    @Select("select * from tenders")
    public List<Tender> getAllTenders();

    @Insert("insert into tenders(id,tenders_label,tenders_name,tenders_time, tenders_end_time, content, pay_money, tenders_status)" +
            "values(#{id},#{tenders_label},#{tenders_name}, #{tenders_time}, #{tenders_end_time}, #{content}, #{pay_money}, #{tenders_status})")
    public Integer tenderCreate(Tender tenders);

    @Delete("DELETE FROM tenders WHERE id = #{id}")
    public void tendersDelete(Integer id);

    @Update("UPDATE tenders SET tenders_label = #{tenders_label}, tenders_name = #{tenders_name}, tenders_end_time = #{tenders_end_time}, content = #{content}" +
            "pay_money = #{pay_money}, tenders_status = #{tenders_status} WHERE id = #{id}")
    public void tendersUpdate(Integer id, String label, String name, String time, String endTime, String content, String payMoney, Integer tender_Status);
}
